package com.ijtunes.sources;

import com.ijtunes.OrganisingExpression;
import com.ijtunes.utils.Properties;
import com.ijtunes.utils.Property;
import com.ijtunes.filetypes.Track;
import java.util.HashMap;

public abstract class TrackSource {

    protected HashMap<String, Track> tracks = new HashMap<String, Track>();
    protected HashMap<String, Track> tracksLocation = new HashMap<String, Track>();
    protected int count = 0;
    protected int upTo = 0;

    protected void add(Track track) {
        if (Properties.getBool(Property.ADD_NEW_FILES)) {
            tracksLocation.put(track.getLocation(), track);
        }
    }
    
    public boolean hasTrack(Track track) {
        return tracks.containsKey(track.getUniqueName());
    }
    
    public Track getTrack(String key) {
        return tracks.get(key);
    }
    
    public void addTrack(Track track) {
        tracks.put(track.getUniqueName(), track);
    }

    public int size() {
        return tracks.size();
    }

    public final boolean hasNext() {
        return (upTo < count);
    }

    public int getUpTo() {
        return upTo;
    }

    public boolean containsLocation(String location) {
        return tracksLocation.containsKey(location);
    }

    public abstract Track getNext();
}
